home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1278 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.dx.net!news
  2. From: robmc@shol.com (Rob McCafferty)
  3. Newsgroups: alt.msdos.programmer,comp.lang.c
  4. Subject: Re: Some C problems
  5. Date: 12 Jan 1996 04:53:27 GMT
  6. Organization: The DataXchange Network, Inc
  7. Message-ID: <4d4pg7$3ot@news.dx.net>
  8. References: <4d0fjj$eok@lugb.latrobe.edu.au>
  9. Reply-To: robmc@shol.com (Rob McCafferty)
  10. NNTP-Posting-Host: 205.148.217.14
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4d0fjj$eok@lugb.latrobe.edu.au>, cs102238@lux.latrobe.edu.au (Gregary John Boyles ) writes:
  14. >     const word MaxBytes=65535; Produces warning : conversion may lose 
  15.  
  16. I believe C assumes numeric constants are signed.  Try using 65535U.
  17.  
  18.  
  19. >DriveSize=DiskInfo.df_total*DiskInfo.df_sclus*DiskInfo.df_bsec;
  20.  
  21. I'm assuming these DiskInfo fields are int's or unsigned int's?  Cast the
  22. expression to long before assigning it: DriveSize=(long)DiskInfo....
  23. >When I want to output a long int type varaible with printf, it prints out
  24. >a garbage value for the variable despite declaring it as a li/ld in the
  25. >format string. What am I doing wrong?
  26.  
  27. Are you 100% absolutely sure that ALL fields in your format string are of
  28. the correct type?
  29.  
  30. >How do you use literal constants bigger than words e.g. how would you use
  31. >the literal constant 1000000 without getting the 'constant out of range'
  32. >warning/error?
  33.  
  34. Again, C assumes constants are int unless you tell it otherwise.  Make this
  35. 1000000L.
  36.  
  37. --Rob
  38.  
  39.